package com.ex03.ylw.connector;

import com.ex03.ylw.connector.http.HttpRequest;

import javax.servlet.ServletInputStream;
import java.io.IOException;

/**
 * servletInputStream 的实现, 用来接收Reqeust，防止多读数据
 *
 * ServletInputStream 主要实现了readline 用户需要实现java.io.InputStream.read()方法
 * Created by yangliwei on 2017/7/25.
 */
public class RequestStream extends ServletInputStream{

    /**
     * Has this stream been closed?
     */
    protected boolean closed = false;


    /**
     * The number of bytes which have already been returned by this stream.
     */
    protected int count = 0;


    /**
     * The content length past which we will not read, or -1 if there is
     * no defined content length.
     */
    protected int length = -1;


    /**
     * 用来接收一个request对象
     * @param request
     */
    public RequestStream(HttpRequest request){
        super();
        closed= false;
        count = 0;
        length = request.getContentLength();
    }


    @Override
    public int read() throws IOException {
        return 0;
    }
}
